<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script>
			// 求和
			let arr = [66,44,55];
			// tmp值中间值,item表示每一项,index表示次数，从1开始
			let result = arr.reduce(function(tmp,item,index){
				// alert(tmp);
				return tmp+item;
			})
			console.log(result);
			//求平均值
			let result2 = arr.reduce(function(tmp,item,index){
				if(index != arr.length-1){
					return tmp+item;
				}else{
					return (tmp+item)/arr.length;
				}
			})
			console.log(result2);
			//数组排序
			let result3 = arr.sort(function(n1,n2){
				return n1-n2;
			})
			console.log(result3); 
		</script>
	</head>
	<body>
	</body>
</html>
